{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "dda3d80e-6c23-46db-af42-5845ed21eb8e",
   "metadata": {},
   "source": [
    "Chapter 05\n",
    "# 字符串定义和操作\n",
    "Book_1《编程不难》 | 鸢尾花书：从加减乘除到机器学习  \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "7d9c5839-bf60-4b32-89ba-dd2fc159b10f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "I am learning Python 101!\n"
     ]
    }
   ],
   "source": [
    "str1 = 'I am learning Python 101!'\n",
    "print(str1)\n",
    "# 打印"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "3d0b47d1-5f40-4146-902f-3959fd816bb8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Python is fun. Machine learning is fun too.\n"
     ]
    }
   ],
   "source": [
    "str2 = \"Python is fun. Machine learning is fun too.\"\n",
    "print(str2)\n",
    "# 打印"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "b5413bff-e0cb-4705-a1eb-f8c7df86ad19",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hey, James!\n"
     ]
    }
   ],
   "source": [
    "# 使用加号 + 将多个字符串连接起来\n",
    "str4 = 'Hey, ' + 'James!'\n",
    "print(str4)  \n",
    "# 'Hey, James!'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "4366fa98-7627-4850-83a9-cb378df04fd8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Python is FUN! Python is FUN! Python is FUN! \n"
     ]
    }
   ],
   "source": [
    "# 使用乘号*将一个字符串复制多次\n",
    "str5 = 'Python is FUN! '  # 字符串最后有一个空格\n",
    "str6 = str5 * 3\n",
    "print(str6)  \n",
    "# 'Python is FUN! Python is FUN! Python is FUN!'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "d298fa27-115f-440e-bf5c-f9999252a301",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "123123123\n"
     ]
    }
   ],
   "source": [
    "# 字符串中的数字仅仅是字符\n",
    "str7 = '123'\n",
    "str8 = str7 * 3\n",
    "print(str8)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "41e35717-1d02-4782-afea-1c758e54341a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "456123\n",
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "str9 = '456'\n",
    "str10 = str9 + str7\n",
    "print(str10)  \n",
    "print(type(str10))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
